<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/6/9 0009
 * Time: 下午 5:56
 */

namespace app\models;
use yii\db\ActiveRecord;
use yii\helpers\ArrayHelper;

use yii\data\Pagination;
use yii\data\ActiveDataProvider;
use yii\data\Sort;
use yii\helpers\Inflector;

class WjSearch extends Wj{

    //public $name;

    public static function tableName()
    {
        return Wj::tableName();
    }

    public function rules()
    {
        return [

            ['name', 'required'],
            ['pwd', 'required'],

        ];

    }

    public function search($params)
    {
        //$where = [];
        $query = Wj::find()->alias('a');



//        $sort = new Sort([
//            'attributes' => [
//                'sort',
//            ],
//        ]);


        //$query->orderBy($sort->orders);
        // 放到这个容器里面才能让列表正常 使用
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
//            'sort' => [//默认排序（排序规则）
//                'defaultOrder' => [
//                    '' => SORT_ASC,
//                ]
//            ],
            'pagination' => [
                'pageSize' => 10,
            ],
        ]);



        if (!($this->load($params) )) {
            return $dataProvider;
        }


        return $dataProvider;


    }
}